var request = require('request');

let _request = {
    post: function (url, data) {
        return new Promise(function (resolve, reject) {
            request(
                {
                    url: url,
                    method: "POST",
                    headers: {
                        "content-type": "application/json",
                    },
                    body: JSON.stringify(data)
                },
                function (error, response, body) {
                    if (error) {
                        reject(error);
                    }
                    else{
                        resolve(body);
                    }
                }
            );
        });
    }
}

module.exports = _request;